// Login.cpp : implementation file
//

#include "stdafx.h"
#include "Login.h"
#include "afxdialogex.h"
#include "MainFrm.h"
#include "UserMessage.h"
// Login dialog

IMPLEMENT_DYNAMIC(CLogin, CDialog)


CLogin::CLogin(CWnd* pParent /*=NULL*/)
	: CDialog(CLogin::IDD, pParent)
{

}

CLogin::~CLogin()
{
}

void CLogin::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_USER_ID, m_editID);
	DDX_Control(pDX, IDC_EDIT_PW, m_editPassword);
	DDX_Control(pDX, IDC_EDIT_SIGN, m_editSignPassword);
}


BEGIN_MESSAGE_MAP(CLogin, CDialog)
	ON_BN_CLICKED(IDOK, &CLogin::OnBnClickedOk)
	ON_BN_CLICKED(IDCANCEL, &CLogin::OnBnClickedCancel)
	ON_MESSAGE(WMU_SETFOCUS, OnUserSetFocus)
END_MESSAGE_MAP()


// Login message handlers

BOOL CLogin::OnInitDialog()
{
	CDialog::OnInitDialog();
	PostMessage(WMU_SETFOCUS, (WPARAM)GetDlgItem(IDC_USER_ID));
	
	CRect rcWindow;  GetWindowRect(rcWindow);
	CRect rcDesktop; CWnd::GetDesktopWindow()->GetClientRect(rcDesktop);
	rcDesktop.top += (rcDesktop.Height() - rcWindow.Height()) >> 1;
	rcDesktop.left += (rcDesktop.Width() - rcWindow.Width()) >> 1;
	SetWindowPos(&wndTop, rcDesktop.left, rcDesktop.top, 0, 0, SWP_NOSIZE);

	return TRUE;
}


void CLogin::OnBnClickedOk()
{
	// TODO: Add your control notification handler code here
	CString strID;
	CString strPassword;
	CString strSignPassword;

	/*
	m_editID.GetWindowText(strID);
	m_editPassword.GetWindowText(strPassword);
	m_editSignPassword.GetWindowText(strSignPassword);
	*/
	strID = "signurs";
	strPassword = "root6017";
	strSignPassword = "root6017";
	CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();
	HWND hnd = pFrame->GetSafeHwnd();
	BOOL isConnect = pFrame->m_wmca.Connect(pFrame->GetSafeHwnd(), CA_WMCAEVENT, 'T', 'W', strID, strPassword, strSignPassword);
}

void CLogin::OnOK()
{
	CDialog::OnOK();
}

void CLogin::OnBnClickedCancel()
{
	// TODO: Add your control notification handler code here
	CDialog::OnCancel();
}

LRESULT CLogin::OnUserSetFocus(WPARAM wParam, LPARAM lParam)
{
	CWnd* pWnd = (CWnd*)wParam;
	pWnd->SetFocus();
	return 0;
}
